home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Music / MIDI / MidiPlay / ARexx / D10Display.rexx next >
OS/2 REXX Batch file  |  1995-08-23  |  1KB  |  76 lines

  1. /* This is an example ARexx script for use with MidiPlay.
  2.    Use the following parameter: FILENAMEREXX=ThisScript.rexx
  3.    When MidiPlay has loaded a new file, it calls ThisScript.
  4.    Argument consists of drive, path, file and extension of the filename.
  5.    This particular example shows the name of the file on the lcd display of
  6.    Roland D10. Modify it to work on your setup.
  7. */
  8.  
  9. options results
  10.  
  11. parse arg Drive ',' Path ',' File ',' Extension .
  12.  
  13. ManuID = 41
  14. DevID = 10
  15. ModelID = 16
  16. CmdID = 12
  17.  
  18. RolandAddress = 20 0 0
  19.  
  20. /* This values can be used with GM modules which recognize SC55 parameters
  21.  
  22. ModelID = 45
  23. RolandAddress = 10 0 0 0 0
  24.  
  25. */
  26.  
  27. address 'MidiPlay_rexx'
  28.  
  29. DataStr = RolandAddress TextToHex(File)
  30.  
  31. Checksum = d2c(128-CalcChecksum(DataStr))
  32.  
  33. 'sysex' ManuID DevID ModelID CmdID DataStr c2x(Checksum)
  34.  
  35. exit
  36.  
  37.  
  38. /* This function converts a text argument to a hexadecimal string */
  39.  
  40. TextToHex:
  41.  
  42. parse arg Str
  43.  
  44. i = 0
  45. HexStr = ""
  46. do while Str ~= ""
  47.     parse var Str first +1 Str2
  48.     r1 = c2x(first)
  49.     if (c2d(first) < 128) then do
  50.         HexStr = HexStr r1
  51.         i = i + 1
  52.     end
  53.     Str = Str2
  54.     if i > 32 then break /* Roland can only display 32 characters */
  55. end
  56.  
  57. return HexStr
  58.  
  59.  
  60. /* This function calculates the checksum of a hexadecimal string */
  61.  
  62. CalcChecksum:
  63.  
  64. parse arg DStr
  65.  
  66. val = 0
  67.  
  68. do while DStr ~= ""
  69.     parse var DStr M1 M2
  70.     r1 = c2d(x2c(M1))
  71.     val = c2d(bitand(d2c(val + r1),'7f'x))
  72.     DStr = M2
  73. end
  74.  
  75. return val
  76.